package com.kai.service.enums;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.experimental.FieldDefaults;

@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@FieldDefaults(level = AccessLevel.PRIVATE)
public enum SmsMailTemplateEnum {

    REGISTER(1, "小凯的博客注册验证码", "您正在注册小凯的博客，验证码%s，5分钟内有效，请不要轻易泄露"),
    UPDATE_PWD(2, "小凯的博客修改密码验证码", "您正在使用修改密码功能，验证码%s，5分钟内有效，请不要轻易泄露");

    int code;
    String subject;
    String content;

    /**
     * 获取短信模板主题
     * @param code
     * @return
     */
    public static String getSubjectByCode(Integer code){
        if(null == code){
            return "";
        }
        SmsMailTemplateEnum[] values = SmsMailTemplateEnum.values();
        for(SmsMailTemplateEnum value : values){
            if(value.code == code){
                return value.subject;
            }
        }
        return "";
    }

    /**
     * 获取短信模板内容
     * @param code
     * @return
     */
    public static String getContentByCode(Integer code){
        if(null == code){
            return "";
        }
        SmsMailTemplateEnum[] values = SmsMailTemplateEnum.values();
        for(SmsMailTemplateEnum value : values){
            if(value.code == code){
                return value.content;
            }
        }
        return "";
    }
}
